<%@ page language="java" import="java.util.*,com.lmpop.trade.ti_attach.*,com.lmpop.trade.uploadFile.*,com.lmpop.frame.util.*,java.io.*" pageEncoding="UTF-8"%>
<link  href="/program/plugins/upload/uploadImg/css.css" rel="stylesheet"  type="text/css" />
<%@ page import="com.lmpop.createIndex.search.*" %>
<%@page import="java.net.URLDecoder"%>
<%
	request.setCharacterEncoding("UTF-8");
	AttachIndexFiles attachIndex = new AttachIndexFiles();
	Hashtable suoMap = new Hashtable();
	
	String com_page = "/saleimageUpload.html";
	
	int limit = 20;
	int start = 0,end = limit;
	int startPage =1;
	if(request.getParameter("start") != null && !request.getParameter("start").equals(""))
	{
		start = Integer.parseInt(request.getParameter("start"));
	}
	String attach_root_id = "",img_type="0",tabShow="0",class_attrs="",area_attrs="",cust_names="",file_type_s="1",filetype="1",old_attach_root_id="";
	
	if(request.getParameter("old_attach_root_id") != null && !request.getParameter("old_attach_root_id").equals(""))
	{
		old_attach_root_id = request.getParameter("old_attach_root_id");
	}
	if(request.getParameter("attach_root_id")!=null && !request.getParameter("attach_root_id").equals("")){
		attach_root_id = request.getParameter("attach_root_id");
	}
	if(request.getParameter("img_type")!=null && !request.getParameter("img_type").equals("")){
		img_type = request.getParameter("img_type");
	}
	if(request.getParameter("tabShow")!=null && !request.getParameter("tabShow").equals("")){
		tabShow = request.getParameter("tabShow");
	}
	if(request.getParameter("class_attrs")!=null && !request.getParameter("class_attrs").equals("")){
		class_attrs = request.getParameter("class_attrs");
	}
	if(request.getParameter("area_attrs")!=null && !request.getParameter("area_attrs").equals("")){
		area_attrs = request.getParameter("area_attrs");
	}
	if(request.getParameter("cust_names")!=null && !request.getParameter("cust_names").equals("")){		 
		cust_names=URLDecoder.decode(request.getParameter("cust_names"),"UTF-8");
	}
	if(request.getParameter("file_type")!=null && !request.getParameter("file_type").equals("")){
		file_type_s = request.getParameter("file_type");
		filetype = request.getParameter("file_type");
	}
	suoMap.put("file_type",file_type_s);	
	suoMap.put("rsrv_str1","1");	
	suoMap.put("rsrv_str6",class_attrs);	
	suoMap.put("rsrv_str7",area_attrs);	
	suoMap.put("rsrv_str8",cust_names);	
	if (!old_attach_root_id.equals("")) suoMap.put("attach_root_id",old_attach_root_id);	
	List imagelist = attachIndex.getAttachList(suoMap);
	
	if (file_type_s.equals("0")) file_type_s = "[ 缩略图 ]";
	if (file_type_s.equals("1")) file_type_s = "[ 详细页面插图 ]";
	if (file_type_s.equals("2")) file_type_s = "[ 大图 ]";
	if (file_type_s.equals("3")) file_type_s = "[ 小图 ]";
	if (file_type_s.equals("5")) file_type_s = "";
	
	if(start==1 || start==0) 
	{
		start = 0;
		startPage = 1;
	}
	else
	{
		startPage = start;
		start = (start-1) * limit;
	}
	end = start + limit;
	int counter = 0;
	if(imagelist!=null && imagelist.size()>0) counter = imagelist.size();
	if(end>counter) 
	{
		end = counter;
		start = counter - limit;
		if(start<0) start = 0;
	}
	String pageStr_class="background: none repeat scroll 0 0 #FF9933;border: 1px solid #FF9933;color: #FFFFFF;";
	PageUtil pageUtil = new PageUtil("[index/]","[uppage/]","[downpage/]","[lastpage/]","","[num/]","[thisnum/]");
	 
	String req_url="?start="+startPage+"&attach_root_id="+attach_root_id+"&img_type="+img_type+"&tabShow="+tabShow+"&class_attrs="+class_attrs+"&area_attrs="+area_attrs+"&cust_names="+cust_names;
	String pageString = pageUtil.getPageString(com_page+req_url,counter,limit,startPage,null,pageStr_class);
%> 
 	<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/interface/Ts_areaInfo.js'></script>
	<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/interface/Ts_categoryInfo.js'></script> 
	<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/engine.js'></script>
	<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/util.js'></script>	
	<script type="text/javascript" src="/program/plugins/upload/uploadImg/upload.js"></script> 
<div class="selecttabs"> 
	<form name="searchform" action="" method="get">
		<input type="hidden" name ="tabShow" value="2">
	 <p><span style="font-size:16px;margin-left:10px;margin-right:10px;color:#FE511F;font-weight:bold;"><br>  请从图片库选择<span style="color:#008080"><%=file_type_s%></span>图片</span> </p>
	 <p>
	  按照分类查找图片：
	    <select  name="sort1s" id="sort1s" onChange="setSecondClasss(this.value);" onclick="setTypeName1s(this)" >
				<option value="">请选择</option>
			</select>			
			<select  name="sort2s" id="sort2s" onChange="setTherdClasss(this.value);" onclick="setTypeName2s(this)">		
				<option value="">请选择</option>
			</select>		
			<select name="sort3s" id="sort3s"  onclick="setTypeName3s(this)">
				<option value="">请选择</option>
			</select>
			
			<input type="hidden" name="attach_root_id" id="attach_root_id" value="<%=attach_root_id%>"/>
			<input type="hidden" name="img_type" id="img_type" value="<%=img_type%>"/>
			<input type="hidden" name="tabShow" id="tabShow" value="<%=tabShow%>"/>
			 
			<input type="hidden" name="cat_attrs" id="cat_attrs" value=""/>
			<input type="hidden" name="class_attrs" id="class_attrs" value="" />
			<input type="hidden" name="area_attrs" id="area_attrs" value="" />
			<input type="hidden" name="class_attr_baks" id="class_attr_baks" value="" />
			<input type="hidden" name="class_id1s" id="class_id1s" value="" />									  
			<input type="hidden" name="class_id2s" id="class_id2s" value="" />
			<input type="hidden" name="class_id3s" id="class_id3s" value="" />
	  </p>
	  <p>
	  按照地区查找图片：
	  <select name="provinces" id="provinces" onclick="setCityss(this.value)">
			  <option value="">省份</option> 
			</select>
			<select name="eparchy_codes" id="eparchy_codes" onclick="setAreass(this.value)">
			  <option value="">地级市</option> 
			 </select>
			<select name="city_codes" id="city_codes" style="display:inline" >
			 <option value="">市、县级市、县</option> 
			</select>
		  <input type="hidden" name="area_attr_baks" id="area_attr_baks" value="" />
	  </p>
	  <p>
	  按照源企名称查找图片：<input type="text" name="cust_names" size="30">			
	  <input type="submit" name="sss" value="查找图片" onclick="searchImg()">
	  </p>
	</form>
</div>			
<div class="selectframe"> 
	
	<ul>
		<%
		 
			if (imagelist!=null  && imagelist.size()>0)
			{
				end = (end > imagelist.size())?imagelist.size():end;
				
				for(int i=start;i<imagelist.size() && i < end;i++)
			  {
		  		String file_path = "",attach_name ="",attach_id="",file_type="",rsrv_str8="",yuanqi="";
		  		Hashtable map = (Hashtable)imagelist.get(i);
		  		if(map.get("file_path")!=null) file_path = map.get("file_path").toString();
		  		if(map.get("attach_name")!=null) attach_name = map.get("attach_name").toString();
		  		if(map.get("attach_id")!=null) attach_id = map.get("attach_id").toString();
		  		if(map.get("file_type")!=null) file_type = map.get("file_type").toString();
		  		if(map.get("rsrv_str8")!=null) rsrv_str8 = map.get("rsrv_str8").toString();
		  		if (file_type.equals("0")) file_type = "缩略图";
		  		if (file_type.equals("1")) file_type = "详细页面插图";
		  		if (file_type.equals("2")) file_type = "大图";
		  		if (file_type.equals("3")) file_type = "小图";
		  		String contentsrc = "<img src="+file_path+"/>";
		  		yuanqi = rsrv_str8;
		  		if(rsrv_str8.length() > 8)
		  		{
						yuanqi = rsrv_str8.substring(0,8);
					}
		 %>
		 	<li><div class="imgcss"><img src="<%=file_path%>" title="<%=rsrv_str8%>"></div>
		 		 <p style="font-size:12px"><%=attach_name%>
		 		 <br>图片类型：<%=file_type%>
		 		 <br>源企：<%=yuanqi%>
		 		 	</p>
		 		 <%
		 		 	if (!filetype.equals("1"))
		 		 	{
		 		 %>
		 		 <p><a href="#" style="color:blue" onclick="doUseImg('<%=attach_id%>','0')">直接引用作为<%=file_type_s%></a></p>
		 		 <p><a href="#" style="color:green" onclick="doUseImg('<%=attach_id%>','1')">引用并拷贝作为<%=file_type_s%></a></p>
		 		 <%
		 		 	}
		 		 %>
		 		 <p><a href="#" style="color:#7C0379" onclick="doUseImg('<%=contentsrc%>','2')">链接插入详细描述</a></p>
		 	</li>
		 <%
		  	}
			}
		else
			{
		%>
			<P>没有符合条件的图片，或者您已经选择了全部所需图片!</P>
		 <%
		 	}
		 %>
	</ul>	 
</div>	
<div style="clear:both;">&nbsp;</div> 	
<div class="pages">
  <%=pageString%>
</div>
  	
<form action="/doTradeReg.do" method="post" name="imageuserform">
     <input type="hidden" name ="attach_root_id" id="attach_root_id" value="<%=attach_root_id%>">
     <input type="hidden" name ="attach_id"  id ="attach_id" value="">
     <input type="hidden" name ="copytag" id ="copytag" value="">
     <input type="hidden" name ="bpm_id" value="2370">
 </form>	
 <script>
setProvinces();
setOneClasss(12);
</script>